<?php
/**
* All Models intended for use with Scribble should extend this base class.
*
* Copyright (c) 2009 James Gauld <james@jamesgauld.net>
* This file is part of Scribble.
* @license http://www.scribblecms.co.uk/license.txt
*
* @package Scribble
*/
use Buan\Config;
use Buan\Model;
class ScribbleModel extends Model {

	/**
	* Constructor. This simply prefixes the model's database table name with the
	* prefix defined in global config.
	*
	* @param string Model name
	* @return ScribbleModel
	*/
	public function __construct($modelName=NULL) {
		parent::__construct($modelName);
		$tblPrefix = Config::get('ext.Scribble.dbTablePrefix');
		$this->dbTableName = "{$tblPrefix}{$this->dbTableName}";
	}

	/**
	* Returns a minimal data object containing information that enables both
	* Scribble and a human user to identify $this model.
	*
	* For display purposes, the result of this method MUST include the following
	* properties:
	*		string id					= The GUID of the model
	*		string modelName	= The model name
	*		string name				= A name by which this model can be recognised by a user
	*
	* @return StdClass
	*/
	public function idMeta() {
		return (object)array(
			'id'=>$this->id,
			'modelName'=>$this->modelName,
			'name'=>"{$this->modelName}:{$this->id}"
		);
	}
}
?>